// api.js
import { $request } from '../utils/request.js';
const token = wx.getStorageSync('token')
//发送验证码
export const sendCode = (mobile) => {
  return $request({
    url: '/account/send/',
    method: "POST",
    data: { mobile: mobile }
  });
};
//绑定手机号
export const bindMobile = (mobile, code) => {
  return $request({
    url: '/account/bind/',
    method: "POST",
    data: { mobile: mobile, code: code },
    header:{
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${token}`
    }
  });
};
//用户登录
export const userLogin = (username, password) =>{
  return $request({
    url:'login/',
    method:"POST",
    data:{
      username:username,
      password:password
    }
  });
};
//用户注册
export const userRegister = (username,password,password2,last_name,email)=>{
  return $request({
    url:"account/register/",
    method:"POST",
    data:{
      username,password,password2,last_name,email
    },
  })
}
//用户退出登录
export const loginOut = ()=>{
  return $request({
    url:'account/logout/',
    method:"POST",
    // header:{
    //   'Content-Type': 'application/json',
    //   'Authorization': `Bearer ${token}`
    // }
  })
}